﻿using System;
namespace Zinnia.Common.Untilty
{
    /// <summary>
    /// Hash缓存
    /// </summary>
    public sealed class HashCacheHelper
    {
        private const string CacheKeyPrefix = "Pwjcy_Lite_HashCacheHelper";
        private System.Collections.Hashtable cacheHashTable = new System.Collections.Hashtable();
        private HashCacheHelper() { }
        public static HashCacheHelper Instance => new HashCacheHelper();
        public void AddCache<T>(T obj, string key)
        {
            if (null != cacheHashTable[CacheKeyPrefix + typeof(T).FullName + key]) return;
            cacheHashTable[CacheKeyPrefix + typeof(T).FullName + key] = obj;
        }
        public T GetCache<T>(string key)
        {
            return (T)cacheHashTable[CacheKeyPrefix + typeof(T).FullName + key];
        }
    }
}
